import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import App from '../App.vue'
import Home from '../page/home.vue'
// import List from '../page/productList/productList.vue'
import Order from '../page/order/order.vue'

import payBack from '../page/orderList/payback.vue'

const myAddress = resolve => {
  require.ensure([], () => {
    resolve(require('../page/order/myAddress.vue'))
  }, 'my-address')
}

const addAddress = resolve => {
  require.ensure([], () => {
    resolve(require('../page/order/addAddress.vue'))
  }, 'add-address')
}

const payMethod = resolve => {
  require.ensure([], () => {
    resolve(require('../page/paymentMethod.vue'))
  }, 'pay-method')
}

const orderList = resolve => {
  require.ensure([], () => {
    resolve(require('../page/orderList/orderList.vue'))
  }, 'order-list')
}

const orderInfo = resolve => {
  require.ensure([], () => {
    resolve(require('../page/orderList/orderInfo.vue'))
  }, 'order-info')
}

const logistics = resolve => {
  require.ensure([], () => {
    resolve(require('../page/orderList/logistics.vue'))
  }, '物流信息')
}

const greenMedical = resolve => {
  require.ensure([], () => {
    resolve(require('../page/greenMedical/greenMedical.vue'))
  }, '绿色就医')
}

const orderDr = resolve => {
  require.ensure([], () => {
    resolve(require('../page/greenMedical/orderDr.vue'))
  }, '预约医生')
}

const chooseDocter = resolve => {
  require.ensure([], () => {
    resolve(require('../page/greenMedical/docterChoose.vue'))
  }, 'chooseDocter')
}

export default new Router({
  routes: [{
    path: '/',
    component: App,
    redirect: '/product-list',
    children: [
      {
        path: '/product-list',
        name: 'home',
        component: Home
      },
      {
        path: '/order/:id',
        name: 'order',
        component: Order
      },
      {
        path: '/my-address',
        name: 'myAddress',
        component: myAddress
      },
      {
        path: '/add-address',
        name: 'add-address',
        component: addAddress
      },
      {
        path: '/pay-method',
        name: 'pay-method',
        component: payMethod
      },
      {
        path: '/order-list/:type',
        name: 'order-list',
        component: orderList
      },
      {
        path: '/order-info/:id',
        name: 'order-info',
        component: orderInfo
      },
      {
        path: '/logistics',
        name: 'logistics',
        component: logistics
      },
      {
        path: '/pay-back',
        name: 'pay-back',
        component: payBack
      },
      {
        path: '/green-medical',
        name: 'green-medical',
        component: greenMedical
      },
      {
        path: '/choose-docter',
        name: 'choose-docter',
        component: chooseDocter
      },
      {
        path: '/order-docter',
        name: 'orderDr',
        component: orderDr
      }
    ]
  }]
})
